<include file="Common:header" />
<TYjs file='fix_table_title'/>
<style> 
.success{width:20%;float:left;}
.success img{width:100%}
</style> 
<div class="table_content">
    <form action="{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/delete_post')}" method="post" class="ajax_form">
        <table class="list_table">
            <tr>
                <th style="min-width:100px;">頭像</th>
                <th style="min-width:80px;">用戶名</th>
                <th style="min-width:80px;">當前所在洗車點</th>
                <th width="130px">操作</th>
            </tr>
            <foreach name='list' item='vo'>
                <tr>
                	<td><img src="{$vo.weixin_avatar}"></td>
                    <td>
                    	{$vo.name}
                    </td>
                    <td>
                    	<foreach name="vo['server_address']" item='v'>
                    	<br/>
                    		{$v.address_name}<br/><br/>
                    	</foreach>
                    </td>                    
                    <td>
                    	<a class="a_btn add_server_name" staff_id="{$vo['id']}" style="margin:10px;cursor:pointer;">配置</a>
                    <!-- <a class="edit" href="{:U(MODULE_NAME.'/Audit/server_info',array('id'=>$vo['id']))}" title="{$Think.lang.edit}"></a>
                    -->  <a class="delete" href="{:U(MODULE_NAME.'/Audit/delete_staff',array('id'=>$vo['id']))}" title="删除"></a>
                    </td>
                </tr>
            </foreach>
        </table>
    </form>
     <div id="add_name" style="display:none;">
	     <form method="post" id="upForm">
	        <table class="edit_table">
	        	<tr>
	                <td class="tablehead">選擇所屬的洗車點</td>
	                <td>
	                	<foreach name="salist" item="sa" key="k" >
	                	<div></div>
	                		<input type="radio" name="select_address" server_address_id="{$sa.id}"  style="height:13px;width:13px;display:block;float:left">{$sa.address_name}
	                		
	                		<if condition="$k%3 eq 0 and $k neq 0">
	                			<br/>
	                		</if><div style="clear:both;"></div>
	                	</foreach>
					</td>
	            </tr>
	                <td class="tablehead"><input type="hidden" name="staff_id"/><input type="hidden" name="server_address_id"/></td>
	                <td><input type="button" name="confirm_send" class="confirm_send" value="确认" style="padding:6px 20px;"/></td>
	            </tr>
	        </table>
	    </form> 
    </div>
    <div class="page">{$page}</div>
</div>
<script type="text/javascript">
    $(function() {
    	$('.add_server_name').click(function(){
    		$('input[name=staff_id]').val($(this).attr('staff_id'));
    		art.dialog({
     			content: document.getElementById('add_name'),
    		});
    	});
    	
    	$('.confirm_send').click(function(){
    		var server_address_id = '';
    		$('input[type=radio]').each(function(){
    			if($(this).prop('checked')){
    				server_address_id = $(this).attr('server_address_id') + ',' + server_address_id;
    			}
    		});
    		$('input[name=server_address_id]').val(server_address_id);
    		var formData = new FormData($( "#upForm" )[0]);
    		$.ajax({    
    	        url: "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/edit_staff_info')}" , 
    	        type: 'POST',    
    	        data : formData,    
    	        async: false,    
    	        cache: false,    
    	        contentType: false,    
    	        processData: false,    
    	        success: function (returndata) {    
    	       		if(returndata.status){
    	       			callBackTips(returndata.status,returndata.info,returndata.url);
    	    		}else{
    	    			callBackTips(0,returndata.info);
    	    		}
    	        },    
    	   });    
    	});
    	
    	$('.change_shopowner_status').click(function() {
            var jsUrl = $(this).attr('url');
            var $this = $(this);
            $this.attr('disabled', true);
            $this.tyAjax({
                isForm: false,
                type: 'get',
                url: jsUrl,
                callBack: function(data) {

                    icon = data.status > 0 ? 'succeed' : 'error';
                    art.dialog({
                        "icon": icon,
                        "title": '消息',
                        "id": "loadding",
                        "lock": true,
                        "fixed": true,
                        "drag": false
                    }).content(data.info).time(1.5);
                    
                    if(data.url != ''){
                    	var interval = setInterval(function() {
                        	clearInterval(interval);
                            window.location.href = data.url;
                        }, jumpTime * 1000);
                    }

                    $this.attr('disabled', false);
                    setTimeout("window.location.reload()",2000)
        
                }
            });
        });
    });
</script>
<include file="Common:footer" />
